***********************************************************************************
* Generate Outlook information using OOH
* last modified 12/21/2022
*
* Note: projection information from OOH
* see appendix table for the paper; also see OOH preface
*
***********************************************************************************


clear
capture log close 
set more off

***************
* Directories *
***************

cd "/Users/"

global dofile			=	"./Code/NEW-OEWS"
global matrix_data		=   "./Data/National Employment Matrix"
global oews_data		= 	"./Data/OEWS/all_excel"
global onet_data		= 	"./OccLink/ONET/ONET data/merged"
global results 			=	"./Results"
global temp				= 	"./Temp"



********************************
* Generate Outlook Variables   *
********************************
use "${temp}/matrix98-20combined.dta", replace

/* 2000 */
gen outlook = 1     if pc_chng >= 36.00 & year == 2000
replace outlook = 2 if inrange(pc_chng, 21.00, 35.99) & year == 2000
replace outlook = 3 if inrange(pc_chng, 10.00, 20.99) & year == 2000
replace outlook = 4 if inrange(pc_chng, 3.00, 9.9) & year == 2000
replace outlook = 5 if inrange(pc_chng, -0.99, 2.99) & year == 2000
replace outlook = 6 if pc_chng <= -1 & year == 2000

/* 2002 */
replace outlook = 1 if pc_chng >= 36.00 & year == 2002
replace outlook = 2 if inrange(pc_chng, 21.00, 35.99) & year == 2002
replace outlook = 3 if inrange(pc_chng, 10.00, 20.99) & year == 2002
replace outlook = 4 if inrange(pc_chng, 3.00, 9.99) & year == 2002
replace outlook = 5 if inrange(pc_chng, -0.99, 2.99) & year == 2002
replace outlook = 6 if pc_chng <= -1 & year == 2002

/* 2004 */
replace outlook = 1 if pc_chng >= 27.00 & year == 2004
replace outlook = 2 if inrange(pc_chng, 18.00, 26.99) & year == 2004
replace outlook = 3 if inrange(pc_chng,  9.00, 17.99) & year == 2004
replace outlook = 4 if inrange(pc_chng,  0.00, 8.99) & year == 2004
replace outlook = 6 if pc_chng <= -0 & year == 2004

/* 2006 */
replace outlook = 1 if pc_chng >= 21.00 & year == 2006
replace outlook = 2 if inrange(pc_chng, 14.00, 20.99) & year == 2006
replace outlook = 3 if inrange(pc_chng,  7.00, 13.99) & year == 2006
replace outlook = 4 if inrange(pc_chng,  3.00,  6.99) & year == 2006
replace outlook = 5 if inrange(pc_chng, -2.99,  2.99) & year == 2006
replace outlook = 7 if inrange(pc_chng, -9.99, -3.00) & year == 2006
replace outlook = 8 if pc_chng <= -10.00 & year == 2006

/* 2008 */
replace outlook = 1 if pc_chng >= 20.00 & year == 2008
replace outlook = 2 if inrange(pc_chng, 14.00, 19.99) & year == 2008
replace outlook = 3 if inrange(pc_chng,  7.00, 13.99) & year == 2008
replace outlook = 4 if inrange(pc_chng,  3.00,  6.99) & year == 2008
replace outlook = 5 if inrange(pc_chng, -2.99,  2.99) & year == 2008
replace outlook = 7 if inrange(pc_chng, -9.99, -3.00) & year == 2008
replace outlook = 8 if pc_chng <= -10.00 & year == 2008


/* 2010 */
replace outlook = 1 if pc_chng >= 29.00 & year == 2010
replace outlook = 2 if inrange(pc_chng, 20.00, 28.99) & year == 2010
replace outlook = 3 if inrange(pc_chng, 10.00, 19.99) & year == 2010
replace outlook = 4 if inrange(pc_chng,  3.00,  9.99) & year == 2010
replace outlook = 5 if inrange(pc_chng, -2.99,  2.99) & year == 2010
replace outlook = 7 if inrange(pc_chng, -9.99, -3.00) & year == 2010
replace outlook = 8 if pc_chng <= -10.00 & year == 2010


/* 2012 */
replace outlook = 1 if pc_chng >= 22.00 & year == 2012
replace outlook = 2 if inrange(pc_chng, 15.00, 21.99) & year == 2012
replace outlook = 3 if inrange(pc_chng,  8.00, 14.99) & year == 2012
replace outlook = 4 if inrange(pc_chng,  3.00,  7.99) & year == 2012
replace outlook = 5 if inrange(pc_chng, -2.99,  2.99) & year == 2012
replace outlook = 6 if pc_chng <= -3.00 & year == 2012

/* 2014 */
replace outlook = 1 if pc_chng >= 14.00 & year == 2014
replace outlook = 2 if inrange(pc_chng,  9.00, 13.99) & year == 2014
replace outlook = 3 if inrange(pc_chng,  5.00,  8.99) & year == 2014
replace outlook = 4 if inrange(pc_chng,  2.00,  4.99) & year == 2014
replace outlook = 5 if inrange(pc_chng, -1.99,  1.99) & year == 2014
replace outlook = 6 if pc_chng <= -2.00 & year == 2014

/* 2016 */
replace outlook = 1 if pc_chng >= 15.00 & year == 2016
replace outlook = 2 if inrange(pc_chng, 10.00, 14.99) & year == 2016
replace outlook = 3 if inrange(pc_chng,  5.00,  9.99) & year == 2016
replace outlook = 4 if inrange(pc_chng,  2.00,  4.99) & year == 2016
replace outlook = 5 if inrange(pc_chng, -1.99,  1.99) & year == 2016
replace outlook = 6 if pc_chng <= -2.00 & year == 2016

/* 2018 */
replace outlook = 1 if pc_chng >= 11.00 & year == 2018
replace outlook = 2 if inrange(pc_chng,  7.00, 10.99) & year == 2018
replace outlook = 3 if inrange(pc_chng,  4.00,  6.99) & year == 2018
replace outlook = 4 if inrange(pc_chng,  2.00,  3.99) & year == 2018
replace outlook = 5 if inrange(pc_chng, -1.99,  1.99) & year == 2018
replace outlook = 6 if pc_chng <= -2.00 & year == 2018

/* 2019 */
replace outlook = 1 if pc_chng >= 8.00 & year == 2019
replace outlook = 2 if inrange(pc_chng,  5.00,  7.99) & year == 2019
replace outlook = 3 if inrange(pc_chng,  3.00,  4.99) & year == 2019
replace outlook = 4 if inrange(pc_chng,  1.00,  2.99) & year == 2019
replace outlook = 5 if inrange(pc_chng, -0.99,  0.99) & year == 2019
replace outlook = 6 if pc_chng <= -1.00 & year == 2019

/* 2020 */
replace outlook = 1 if pc_chng >= 16.00 & year == 2020
replace outlook = 2 if inrange(pc_chng, 11.00, 15.99) & year == 2020
replace outlook = 3 if inrange(pc_chng,  6.00, 10.99) & year == 2020
replace outlook = 4 if inrange(pc_chng,  2.00,  5.99) & year == 2020
replace outlook = 5 if inrange(pc_chng, -1.99,  1.99) & year == 2020
replace outlook = 6 if pc_chng <= -2.00 & year == 2020


lab def outlook 1 "much faster than average"     ///
				2 "faster than average"          ///
				3 "as fast as average"           ///
				4 "slower than average"          ///
				5 "little or no change"          /// 
				6 "decline"                      ///
				7 "decline slowly or moderately" ///
				8 "decline rapidly"
				
lab val outlook outlook

recode outlook (1 2 3 = 1 "growth") (4 5 = 2 "stable") (6 7 8 = 3 "decline"), gen(outlook_gr)

save "${temp}/matrix-ooh98-20combined.dta", replace

